import org.junit.Test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalTime;
import java.util.Date;

public class testMethod {

    @Test
    public void test(){
        Date date=new Date();
        System.out.println(date);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy:MM:dd HH:mm:ss");
        System.out.println("当前时间: " + sdf.format(date));
        if(sdf.format(date).compareTo("2023:04:15 11:44:16")>0){
            System.out.println("大于2022年");
        }else{
            System.out.println("小于2022年");
        }
        try {
            System.out.println(sdf.parse(sdf.format(date)));
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}
